/*
 * Copyright (c) 2003, 2004 Ulrich Hilger, http://dev.uhilger.de, all rights reserved.
 *
 * Published under the terms and conditions of the Apache License 2.0,
 * see http://www.apache.org/licenses/LICENSE-2.0
 */

package de.uhilger.app.action;

import javax.swing.AbstractAction;
import java.awt.event.*;
import javax.help.HelpBroker;
import javax.help.CSH;
import de.uhilger.app.Application;
import javax.swing.KeyStroke;

/**
 * action to show help
 *
 * @author Ulrich Hilger, <a href="http://dev.uhilger.de" target="_blank">http://dev.uhilger.de</a>
 * @author Published under the terms and conditions of
 * the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License 2.0</a>
 *
 * @version 2, February 12, 2004
 */

public class HelpContentsAction extends AbstractAction {

  /**
   * constructor
   */
  public HelpContentsAction() {
    super();
    putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    try {
      HelpBroker hb = Application.getHelpBroker();
      if(hb != null) {
        al = new CSH.DisplayHelpFromSource(hb);
      }
    }
    catch(Exception e) {
      Application.logStackTrace(e, getClass());
    }
  }

  /**
   * show help
   * @param e ActionEvent
   */
  public void actionPerformed(ActionEvent e) {
    try {
      al.actionPerformed(e);
    }
    catch (Exception ex) {
      Application.logStackTrace(ex, getClass());
    }
  }

  /** ActionListener this action uses */
  private ActionListener al;
}
